#include <COMMON_HEADER/common_header.h>
/*
 * Copyright (c) 2016-2020, Chengdu RST technology co., ltd
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-01-05     shijiabao       the first version
 */

/*使用PE2 PE3两个引脚作为LED1 LED2 */
#define LED1_PIN_NUM 66
#define LED2_PIN_NUM 67
#define LED3_PIN_NUM 68

uint8_t led_connect_status = 0;
uint8_t led_network_status = 0;

void led_init(void)
{
    /*引脚为输出模式 */
    rt_pin_mode(LED1_PIN_NUM,PIN_MODE_OUTPUT);
    rt_pin_mode(LED2_PIN_NUM,PIN_MODE_OUTPUT);
    rt_pin_mode(LED3_PIN_NUM,PIN_MODE_OUTPUT);

    /*默认高电平 */
    led1_on();
    led2_on();
    led3_on();
    rt_thread_mdelay(1000);
    led1_down();
    led2_down();
    led3_down();
}

void led1_on(void)
{
    rt_pin_write(LED1_PIN_NUM, PIN_HIGH);
}

void led2_on(void)
{
    rt_pin_write(LED2_PIN_NUM, PIN_HIGH);
}

void led3_on(void)
{
    rt_pin_write(LED3_PIN_NUM, PIN_HIGH);
}

void led1_down(void)
{
    rt_pin_write(LED1_PIN_NUM, PIN_LOW);
}

void led2_down(void)
{
    rt_pin_write(LED2_PIN_NUM, PIN_LOW);
}

void led3_down(void)
{
    rt_pin_write(LED3_PIN_NUM, PIN_LOW);
}

void led2_twinkle(void)
{
    led2_on();
    rt_thread_mdelay(100);
    led2_down();
}

void led_network_status_change(uint8_t status)
{
    if(led_network_status != 3)
    {
        led_network_status = status;
    }
}

void led_connect_status_change(uint8_t status)
{
    if(led_connect_status != 3)
    {
        led_connect_status = status;
    }
}
